from flask_marshmallow import base_fields
from flask_restplus_patched import ModelSchema
from app.modules.common.schemas import BaseSchema
from .models import Role

class BaseRoleSchema(ModelSchema):
    class Meta:
        model = Role
        fields = (
            Role.role_id.key,
            Role.role_name.key,
            Role.desc.key,
        )

        dump_only = (
            Role.role_id.key,
        )

class RoleSchema(BaseSchema):
    data = base_fields.Nested(
        BaseRoleSchema,
        many = True
    )
    class Meta:
        fields = BaseSchema.Meta.fields + (
            'data',
        )

class RoleAddSchema(BaseSchema):
    data = base_fields.Nested(
        BaseRoleSchema,
        many = False
    )
    class Meta:
        fields = BaseSchema.Meta.fields + (
            'data',
        )